<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Returns a geographic scale. The arguments to this constructor are optional,
<span class='line'>  3</span>  * and equivalent to calling {@link #projection}.
<span class='line'>  4</span>  *
<span class='line'>  5</span>  * @class Represents a geographic scale; a mapping between latitude-longitude
<span class='line'>  6</span>  * coordinates and screen pixel coordinates. By default, the domain is inferred
<span class='line'>  7</span>  * from the geographic coordinates, so that the domain fills the output range.
<span class='line'>  8</span>  *
<span class='line'>  9</span>  * &lt;p>Note that geographic scales are two-dimensional transformations, rather
<span class='line'> 10</span>  * than the one-dimensional bidrectional mapping typical of other scales.
<span class='line'> 11</span>  * Rather than mapping (for example) between a numeric domain and a numeric
<span class='line'> 12</span>  * range, geographic scales map between two coordinate objects: {@link
<span class='line'> 13</span>  * pv.Geo.LatLng} and {@link pv.Vector}.
<span class='line'> 14</span>  *
<span class='line'> 15</span>  * @param {pv.Geo.Projection} [p] optional projection.
<span class='line'> 16</span>  * @see pv.Geo.scale#ticks
<span class='line'> 17</span>  */</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="NAME">pv.Geo.scale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rmin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default range minimum</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT">      </span><span class="NAME">rmax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default range maximum</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">      </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// default domain</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT">      </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Geo.projections.identity</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// domain &lt;-> normalized range</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="WHIT">      </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Scale.linear</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">range</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// normalized &lt;-> range</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="WHIT">      </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Scale.linear</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">range</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// normalized &lt;-> range</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT">      </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">lng</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lat</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// Center Point</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">      </span><span class="NAME">lastLatLng</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// cached latlng</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">      </span><span class="NAME">lastPoint</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// cached point</span><span class="WHIT">
<span class='line'> 28</span> 
<span class='line'> 29</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">(</span><span class="NAME">latlng</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">lastLatLng</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">        </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">latlng.lng</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">lastLatLng.lng</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">        </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">latlng.lat</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">lastLatLng.lat</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">      </span><span class="NAME">lastLatLng</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">latlng</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">project</span><span class="PUNC">(</span><span class="NAME">latlng</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">      </span><span class="NAME">lastPoint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">(</span><span class="NAME">p.x</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">(</span><span class="NAME">p.y</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">lastPoint</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 40</span> 
<span class='line'> 41</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">project</span><span class="PUNC">(</span><span class="NAME">latlng</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">offset</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">lng</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">latlng.lng</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">c.lng</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lat</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">latlng.lat</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">j.project</span><span class="PUNC">(</span><span class="NAME">offset</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 46</span> 
<span class='line'> 47</span> </span><span class="WHIT">  </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">invert</span><span class="PUNC">(</span><span class="NAME">xy</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">latlng</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">j.invert</span><span class="PUNC">(</span><span class="NAME">xy</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">    </span><span class="NAME">latlng.lng</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">c.lng</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">latlng</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 53</span> 
<span class='line'> 54</span> </span><span class="WHIT">  </span><span class="COMM">/** Returns the projected x-coordinate. */</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">  </span><span class="NAME">scale.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">latlng</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">(</span><span class="NAME">latlng</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> 
<span class='line'> 59</span> </span><span class="WHIT">  </span><span class="COMM">/** Returns the projected y-coordinate. */</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">  </span><span class="NAME">scale.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">latlng</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">(</span><span class="NAME">latlng</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> 
<span class='line'> 64</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 65</span>    * Abstract; this is a local namespace on a given geographic scale.
<span class='line'> 66</span>    *
<span class='line'> 67</span>    * @namespace Tick functions for geographic scales. Because geographic scales
<span class='line'> 68</span>    * represent two-dimensional transformations (as opposed to one-dimensional
<span class='line'> 69</span>    * transformations typical of other scales), the tick values are similarly
<span class='line'> 70</span>    * represented as two-dimensional coordinates in the input domain, i.e.,
<span class='line'> 71</span>    * {@link pv.Geo.LatLng} objects.
<span class='line'> 72</span>    *
<span class='line'> 73</span>    * &lt;p>Also, note that non-rectilinear projections, such as sinsuoidal and
<span class='line'> 74</span>    * aitoff, may not produce straight lines for constant longitude or constant
<span class='line'> 75</span>    * latitude. Therefore the returned array of ticks is a two-dimensional array,
<span class='line'> 76</span>    * sampling various latitudes as constant longitude, and vice versa.
<span class='line'> 77</span>    *
<span class='line'> 78</span>    * &lt;p>The tick lines can therefore be approximated as polylines, either with
<span class='line'> 79</span>    * "linear" or "cardinal" interpolation. This is not as accurate as drawing
<span class='line'> 80</span>    * the true curve through the projection space, but is usually sufficient.
<span class='line'> 81</span>    *
<span class='line'> 82</span>    * @name pv.Geo.scale.prototype.ticks
<span class='line'> 83</span>    * @see pv.Geo.scale
<span class='line'> 84</span>    * @see pv.Geo.LatLng
<span class='line'> 85</span>    * @see pv.Line#interpolate
<span class='line'> 86</span>    */</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">  </span><span class="NAME">scale.ticks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 88</span> 
<span class='line'> 89</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 90</span>      * Returns longitude ticks.
<span class='line'> 91</span>      *
<span class='line'> 92</span>      * @function
<span class='line'> 93</span>      * @param {number} [m] the desired number of ticks.
<span class='line'> 94</span>      * @returns {array} a nested array of &lt;tt>pv.Geo.LatLng&lt;/tt> ticks.
<span class='line'> 95</span>      * @name pv.Geo.scale.prototype.ticks.prototype.lng
<span class='line'> 96</span>      */</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">    </span><span class="NAME">lng</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">lat</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lng</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.Scale.linear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">        </span><span class="NAME">lat</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.domain</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d.lat</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">ticks</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">        </span><span class="NAME">lng</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.domain</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d.lng</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">ticks</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">        </span><span class="NAME">lat</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.range</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">80</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">81</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">        </span><span class="NAME">lng</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.range</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">180</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">181</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">lng.map</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">lng</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">lat.map</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">lat</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">lat</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">lat</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lng</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">lng</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>114</span> 
<span class='line'>115</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>116</span>      * Returns latitude ticks.
<span class='line'>117</span>      *
<span class='line'>118</span>      * @function
<span class='line'>119</span>      * @param {number} [m] the desired number of ticks.
<span class='line'>120</span>      * @returns {array} a nested array of &lt;tt>pv.Geo.LatLng&lt;/tt> ticks.
<span class='line'>121</span>      * @name pv.Geo.scale.prototype.ticks.prototype.lat
<span class='line'>122</span>      */</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">    </span><span class="NAME">lat</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pv.transpose</span><span class="PUNC">(</span><span class="NAME">scale.ticks.lng</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>127</span> 
<span class='line'>128</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>129</span>    * Inverts the specified value in the output range, returning the
<span class='line'>130</span>    * corresponding value in the input domain. This is frequently used to convert
<span class='line'>131</span>    * the mouse location (see {@link pv.Mark#mouse}) to a value in the input
<span class='line'>132</span>    * domain. Inversion is only supported for numeric ranges, and not colors.
<span class='line'>133</span>    *
<span class='line'>134</span>    * &lt;p>Note that this method does not do any rounding or bounds checking. If
<span class='line'>135</span>    * the input domain is discrete (e.g., an array index), the returned value
<span class='line'>136</span>    * should be rounded. If the specified &lt;tt>y&lt;/tt> value is outside the range,
<span class='line'>137</span>    * the returned value may be equivalently outside the input domain.
<span class='line'>138</span>    *
<span class='line'>139</span>    * @function
<span class='line'>140</span>    * @name pv.Geo.scale.prototype.invert
<span class='line'>141</span>    * @param {number} y a value in the output range (a pixel location).
<span class='line'>142</span>    * @returns {number} a value in the input domain.
<span class='line'>143</span>    */</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">  </span><span class="NAME">scale.invert</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">invert</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">x.invert</span><span class="PUNC">(</span><span class="NAME">p.x</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">y.invert</span><span class="PUNC">(</span><span class="NAME">p.y</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> 
<span class='line'>148</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>149</span>    * Sets or gets the input domain. Note that unlike quantitative scales, the
<span class='line'>150</span>    * domain cannot be reduced to a simple rectangle (i.e., minimum and maximum
<span class='line'>151</span>    * values for latitude and longitude). Instead, the domain values must be
<span class='line'>152</span>    * projected to normalized space, effectively finding the domain in normalized
<span class='line'>153</span>    * space rather than in terms of latitude and longitude. Thus, changing the
<span class='line'>154</span>    * projection requires recomputing the normalized domain.
<span class='line'>155</span>    *
<span class='line'>156</span>    * &lt;p>This method can be invoked several ways:
<span class='line'>157</span>    *
<span class='line'>158</span>    * &lt;p>1. &lt;tt>domain(values...)&lt;/tt>
<span class='line'>159</span>    *
<span class='line'>160</span>    * &lt;p>Specifying the domain as a series of {@link pv.Geo.LatLng}s is the most
<span class='line'>161</span>    * explicit and recommended approach. However, if the domain values are
<span class='line'>162</span>    * derived from data, you may find the second method more appropriate.
<span class='line'>163</span>    *
<span class='line'>164</span>    * &lt;p>2. &lt;tt>domain(array, f)&lt;/tt>
<span class='line'>165</span>    *
<span class='line'>166</span>    * &lt;p>Rather than enumerating the domain explicitly, you can specify a single
<span class='line'>167</span>    * argument of an array. In addition, you can specify an optional accessor
<span class='line'>168</span>    * function to extract the domain values (as {@link pv.Geo.LatLng}s) from the
<span class='line'>169</span>    * array. If the specified array has fewer than two elements, this scale will
<span class='line'>170</span>    * default to the full normalized domain.
<span class='line'>171</span>    *
<span class='line'>172</span>    * &lt;p>2. &lt;tt>domain()&lt;/tt>
<span class='line'>173</span>    *
<span class='line'>174</span>    * &lt;p>Invoking the &lt;tt>domain&lt;/tt> method with no arguments returns the
<span class='line'>175</span>    * current domain as an array.
<span class='line'>176</span>    *
<span class='line'>177</span>    * @function
<span class='line'>178</span>    * @name pv.Geo.scale.prototype.domain
<span class='line'>179</span>    * @param {...} domain... domain values.
<span class='line'>180</span>    * @returns {pv.Geo.scale} &lt;tt>this&lt;/tt>, or the current domain.
<span class='line'>181</span>    */</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">  </span><span class="NAME">scale.domain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">      </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">array</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">          </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">pv.map</span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Array.prototype.slice.call</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">lngs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.map</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">c.lng</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">lats</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.map</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">c.lat</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">        </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">          </span><span class="NAME">lng</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pv.max</span><span class="PUNC">(</span><span class="NAME">lngs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pv.min</span><span class="PUNC">(</span><span class="NAME">lngs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">          </span><span class="NAME">lat</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pv.max</span><span class="PUNC">(</span><span class="NAME">lats</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pv.min</span><span class="PUNC">(</span><span class="NAME">lats</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.map</span><span class="PUNC">(</span><span class="NAME">project</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// normalized domain</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">        </span><span class="NAME">x.domain</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">p.x</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">        </span><span class="NAME">y.domain</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">p.y</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">        </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">lng</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lat</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">        </span><span class="NAME">x.domain</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">        </span><span class="NAME">y.domain</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">      </span><span class="NAME">lastLatLng</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// invalidate the cache</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>207</span> 
<span class='line'>208</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>209</span>    * Sets or gets the output range. This method can be invoked several ways:
<span class='line'>210</span>    *
<span class='line'>211</span>    * &lt;p>1. &lt;tt>range(min, max)&lt;/tt>
<span class='line'>212</span>    *
<span class='line'>213</span>    * &lt;p>If two objects are specified, the arguments should be {@link pv.Vector}s
<span class='line'>214</span>    * which specify the minimum and maximum values of the x- and y-coordinates
<span class='line'>215</span>    * explicitly.
<span class='line'>216</span>    *
<span class='line'>217</span>    * &lt;p>2. &lt;tt>range(width, height)&lt;/tt>
<span class='line'>218</span>    *
<span class='line'>219</span>    * &lt;p>If two numbers are specified, the arguments specify the maximum values
<span class='line'>220</span>    * of the x- and y-coordinates explicitly; the minimum values are implicitly
<span class='line'>221</span>    * zero.
<span class='line'>222</span>    *
<span class='line'>223</span>    * &lt;p>3. &lt;tt>range()&lt;/tt>
<span class='line'>224</span>    *
<span class='line'>225</span>    * &lt;p>Invoking the &lt;tt>range&lt;/tt> method with no arguments returns the current
<span class='line'>226</span>    * range as an array of two {@link pv.Vector}s: the minimum (top-left) and
<span class='line'>227</span>    * maximum (bottom-right) values.
<span class='line'>228</span>    *
<span class='line'>229</span>    * @function
<span class='line'>230</span>    * @name pv.Geo.scale.prototype.range
<span class='line'>231</span>    * @param {...} range... range values.
<span class='line'>232</span>    * @returns {pv.Geo.scale} &lt;tt>this&lt;/tt>, or the current range.
<span class='line'>233</span>    */</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">  </span><span class="NAME">scale.range</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">min</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">max</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">min</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">        </span><span class="NAME">rmin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">min.x</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">min.y</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">        </span><span class="NAME">rmax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">max.x</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">max.y</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">        </span><span class="NAME">rmin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">        </span><span class="NAME">rmax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">min</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">max</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">      </span><span class="NAME">x.range</span><span class="PUNC">(</span><span class="NAME">rmin.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rmax.x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">      </span><span class="NAME">y.range</span><span class="PUNC">(</span><span class="NAME">rmax.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rmin.y</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// XXX flipped?</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">      </span><span class="NAME">lastLatLng</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// invalidate the cache</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">rmin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rmax</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>250</span> 
<span class='line'>251</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>252</span>    * Sets or gets the projection. This method can be invoked several ways:
<span class='line'>253</span>    *
<span class='line'>254</span>    * &lt;p>1. &lt;tt>projection(string)&lt;/tt>
<span class='line'>255</span>    *
<span class='line'>256</span>    * &lt;p>Specifying a string sets the projection to the given named projection in
<span class='line'>257</span>    * {@link pv.Geo.projections}. If no such projection is found, the identity
<span class='line'>258</span>    * projection is used.
<span class='line'>259</span>    *
<span class='line'>260</span>    * &lt;p>2. &lt;tt>projection(object)&lt;/tt>
<span class='line'>261</span>    *
<span class='line'>262</span>    * &lt;p>Specifying an object sets the projection to the given custom projection,
<span class='line'>263</span>    * which must implement the &lt;i>forward&lt;/i> and &lt;i>inverse&lt;/i> methods per the
<span class='line'>264</span>    * {@link pv.Geo.Projection} interface.
<span class='line'>265</span>    *
<span class='line'>266</span>    * &lt;p>3. &lt;tt>projection()&lt;/tt>
<span class='line'>267</span>    *
<span class='line'>268</span>    * &lt;p>Invoking the &lt;tt>projection&lt;/tt> method with no arguments returns the
<span class='line'>269</span>    * current object that defined the projection.
<span class='line'>270</span>    *
<span class='line'>271</span>    * @function
<span class='line'>272</span>    * @name pv.Scale.geo.prototype.projection
<span class='line'>273</span>    * @param {...} range... range values.
<span class='line'>274</span>    * @returns {pv.Scale.geo} &lt;tt>this&lt;/tt>, or the current range.
<span class='line'>275</span>    */</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">  </span><span class="NAME">scale.projection</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">      </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">          </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">pv.Geo.projections</span><span class="PUNC">[</span><span class="NAME">p</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">pv.Geo.projections.identity</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.domain</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// recompute normalized domain</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>285</span> 
<span class='line'>286</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>287</span>    * Returns a view of this scale by the specified accessor function &lt;tt>f&lt;/tt>.
<span class='line'>288</span>    * Given a scale &lt;tt>g&lt;/tt>, &lt;tt>g.by(function(d) d.foo)&lt;/tt> is equivalent to
<span class='line'>289</span>    * &lt;tt>function(d) g(d.foo)&lt;/tt>. This method should be used judiciously; it
<span class='line'>290</span>    * is typically more clear to invoke the scale directly, passing in the value
<span class='line'>291</span>    * to be scaled.
<span class='line'>292</span>    *
<span class='line'>293</span>    * @function
<span class='line'>294</span>    * @name pv.Geo.scale.prototype.by
<span class='line'>295</span>    * @param {function} f an accessor function.
<span class='line'>296</span>    * @returns {pv.Geo.scale} a view of this scale by the specified accessor
<span class='line'>297</span>    * function.
<span class='line'>298</span>    */</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">  </span><span class="NAME">scale.by</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">by</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">(</span><span class="NAME">f.apply</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">method</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">by</span><span class="PUNC">[</span><span class="NAME">method</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">[</span><span class="NAME">method</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">by</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>304</span> 
<span class='line'>305</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">scale.projection</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>307</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span></pre></body></html>